package com.example.mybatisplusproject.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.mybatisplusproject.dao.UserDAO;
import com.example.mybatisplusproject.entity.User;
import com.example.mybatisplusproject.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author zls
 * @date 2021/7/10 4:39 下午
 */
@Service
@Slf4j
public class UserServiceImpl extends ServiceImpl<UserDAO, User> implements UserService {
    @Resource
    private UserDAO userDAO;

    @Override
    public boolean saveByMapper(User user) {
        return userDAO.insert(user) == 1;
    }

    @Override
    @Cacheable(value = "noargs")
    public String test0() {
        return "0";
    }

    @Override
    @Cacheable(value = "oneargs")
    public String test1(String id) {
        return id;
    }

    @Override
    @Cacheable(value = "twoargs")
    public String test2(String id, String name) {
        return id + "_" + name;
    }

    @Override
    @CacheEvict(value = "noargs")
    public String test3() {
        return null;
    }

    @Override
    @CacheEvict(value = "oneargs")
    public String test4(String id) {
        return null;
    }

    @Override
    @CacheEvict(value = "twoargs")
    public String test5(String id, String name) {
        return null;
    }
}
